home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************/
- /* (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved */
- /*****************************************************************************/
- /* This source-code is NOT public domain nor Freeware, this is part of */
- /* 'The C Programming Package' which is Shareware. */
- /* If you use this code, please register and get a free Full-VGA version */
- /*****************************************************************************/
- /*----------------*
- * CPPLMENU.C *
- * Main menu Mgr *
- *----------------*/
-
- /* Included Files */
- # include <stdio.h>
- # include <io.h>
- # include <dos.h>
- # include <fcntl.h>
- # include <bios.h>
- # include <stdlib.h>
- # include <conio.h>
-
- /* Global Variables */
- extern int bm,i,j,k,l,m,n,t,x,x1,x2,xm,y,y1,y2,ym,z,menu0,return0;
- extern int colour1,colour2,colour3,colour4,colour5;
- extern unsigned char c0,c1,trashcan[];
-
- /*---------------*
- * DISPLAY MENU0 *
- *---------------*/
- void display_menu0()
- {
- /* We display the first menu line and today's date */
- /* This will be permanently displayed */
- /* To avoid mouse traces, we hide it and show it after */
- hide_the_mouse();
- textattr(colour1); clrscr();
- textattr(colour2); gotoxy(1,1);
- cputs(" Files Menu2 Menu3 Menu4 Menu5 Menu6 Menu7 Menu8 Config. Help ");
- /* Display the system date in the upper-right corner */
- get_date_text_format();
- gotoxy(69,2); cputs("╔══════════╗");
- gotoxy(69,3); cputs("║ ║");
- gotoxy(69,4); cputs("╚══════════╝");
- gotoxy(71,3); cputs(trashcan);
- /* We display the letter keys in red over lightgrey */
- textattr(116);
- gotoxy(2,1); cputs("F");
- gotoxy(15,1); cputs("2");
- gotoxy(23,1); cputs("3");
- gotoxy(31,1); cputs("4");
- gotoxy(39,1); cputs("5");
- gotoxy(47,1); cputs("6");
- gotoxy(55,1); cputs("7");
- gotoxy(63,1); cputs("8");
- gotoxy(67,1); cputs("C");
- gotoxy(76,1); cputs("H");
- show_the_mouse();
- }
- /*----------------*
- * GET THE MOUSE0 *
- *----------------*/
- int get_the_mouse0()
- {
- /* If we choose with the mouse */
- /* Only available for menu 0 */
- if((ym>0)&&(ym<3)){
- if((xm>0)&&(xm<10)){
- /* Choice Files menu */
- return(1);
- }
- if((xm>9)&&(xm<18)){
- /* Choice menu2 */
- return(2);
- }
- if((xm>17)&&(xm<26)){
- /* Choice menu3 */
- return(3);
- }
- if((xm>25)&&(xm<34)){
- /* Choice menu4 */
- return(4);
- }
- if((xm>33)&&(xm<42)){
- /* Choice menu5 */
- return(5);
- }
- if((xm>41)&&(xm<50)){
- /* Choice menu6 */
- return(6);
- }
- if((xm>49)&&(xm<58)){
- /* Choice menu7 */
- return(7);
- }
- if((xm>57)&&(xm<66)){
- /* Choice menu8 */
- return(8);
- }
- if((xm>65)&&(xm<74)){
- /* Choice Configuration menu*/
- return(9);
- }
- if((xm>73)&&(xm<=80)){
- /* Choice help menu */
- return(10);
- }
- }
- /* If the co-ordinates does not match we erase the menu */
- return(0);
- }
- /*--------------------*
- * GET SPECIAL MENU00 *
- *--------------------*/
- int get_special_menu00()
- {
- if(c1==77){
- /* Right arrow */
- if(menu0<10) menu0++;
- else menu0=1;
- return(1);
- }
- if(c1==75){
- /* Left arrow */
- if(menu0>1) menu0--;
- else menu0=10;
- return(1);
- }
- if(c1==33){
- /* Alt + F = Call menu1 */
- menu0=1; return(1);
- }
- if(c1==121){
- /* Alt + 2 = Call menu2 */
- menu0=2; return(1);
- }
- if(c1==122){
- /* Alt + 3 = Call menu3 */
- menu0=3; return(1);
- }
- if(c1==123){
- /* Alt + 4 = Call menu4 */
- menu0=4; return(1);
- }
- if(c1==124){
- /* Alt + 5 = Call menu5 */
- menu0=5; return(1);
- }
- if(c1==125){
- /* Alt + 6 = Call menu6 */
- menu0=6; return(1);
- }
- if(c1==126){
- /* Alt + 7 = Call menu7 */
- menu0=7; return(1);
- }
- if(c1==127){
- /* Alt + 8 = Call menu8 */
- menu0=8; return(1);
- }
- if(c1==46){
- /* Alt + C = Call menuC */
- menu0=9; return(1);
- }
- if(c1==35){
- /* Alt + H = Call menuH */
- menu0=10; return(1);
- }
- return(0);
- }
- /*------------------------*
- * DISPLAY SELECTED MENU0 *
- *------------------------*/
- void display_selected_menu0()
- {
- /* We display what was on the screen before the menu call */
- restore_screen();
- if(menu0==1) display_menu1();
- if(menu0==2) display_menu2();
- if(menu0==3) display_menu3();
- if(menu0==4) display_menu4();
- if(menu0==5) display_menu5();
- if(menu0==6) display_menu6();
- if(menu0==7) display_menu7();
- if(menu0==8) display_menu8();
- if(menu0==9) display_menu9();
- if(menu0==10) display_menu10();
- }
- /*--------------*
- * MENU CHOICE0 *
- *--------------*/
- void menu_choice0()
- {
- /* We do nothing until a key is pressed */
- /* or we pressed a mouse button. */
- while(1){
- if(kbhit()){
- /* If we pressed a key */
- c1=getch();
- if((c1==65)||(c1==97)){
- /* Only direct call allowed to get the help */
- i=10; break;
- }
- if(c1==0){
- /* Key coded on 2 bytes, we get the second byte */
- c1=getch(); get_special_menu00();
- i=menu0; break;
- }
- }
- /* Else we test the mouse */
- get_mouse_state();
- if(bm==1){
- /* We pressed a mouse button */
- i=get_the_mouse0(); break;
- }
- }
- /* We translate the result and send it back */
- menu0=i;
- }
- /*-------------------*
- * MAIN MENU MANAGER *
- *-------------------*/
- void main_menu_manager()
- {
- /* We save the screen before displaying the menu because */
- /* we will restore the whole screen but the first line */
- display_menu0(); hide_the_mouse();
- /* During the saving we hide the mouse to avoid traces */
- /* in case of mouse moving */
- save_screen(); show_the_mouse();
- return0=0;
- while(1){
- /* When we changed of menu by an arrow, we do not ask for a new */
- /* choice. */
- if(return0!=-2) menu_choice0();
- display_selected_menu0(); return0=0;
- if(menu0==1) return0=menu_manager1();
- if(menu0==2) return0=menu_manager2();
- if(menu0==3) return0=menu_manager3();
- if(menu0==4) return0=menu_manager4();
- if(menu0==5) return0=menu_manager5();
- if(menu0==6) return0=menu_manager6();
- if(menu0==7) return0=menu_manager7();
- if(menu0==8) return0=menu_manager8();
- if(menu0==9) return0=menu_manager9();
- if(menu0==10) return0=menu_manager10();
- if(return0==-1) return;
- }
- }
- /* End of the Module */ /*-----------------------*/
-